import { get, post, IList } from "./index";

export interface Training {
    name: string;
    algorithmName: string;
    algorithmId: number;
    dataSetName: string;
    dataSetId: number;
    createTime: string;
    id: number;
    remark: string;
    status: number; // 状态：1，待启动；2，启动；3：进行中；4:结束
}

interface ListQuery {
    page: number;
    pageSize: number;
    name?: string;
}

// 获取训练列表
export const getTrainings = async (data: ListQuery): Promise<IList<Training>> => {
    const res = await post("/training/list", data);
    return { list: res.data.trainingDtoList || [], total: res.data.total };
};

// 删除训练
export const delTraining = async (id: number) => post("/training/delete", { id });

export interface CreateTraining {
    algorithmId: number;
    dataSetId: number;
    name: string;
}

// 新建训练
export const createTraining = async (data: CreateTraining) => post("/training/create", data);

// 更新训练
export const updateTraining = async (data: CreateTraining & { id: number }) =>
    post("/training/update", data);
